package message;

import enums.MessageTypeEnum;

import java.nio.charset.StandardCharsets;

/**
 * 文本类型的消息
 * @author wb_zhulinzhong
 * @date 2021-04-14 16:49:11
 */
public class StringMessage extends Message{

    public StringMessage() {
        super();
    }

    public StringMessage(String message) {
        super(null, null, message.getBytes(StandardCharsets.UTF_8));
    }
    public StringMessage(String uId, String message) {
        super(uId, null, message.getBytes(StandardCharsets.UTF_8));
    }
    public StringMessage(String uId, String toUId, String message) {
        super(uId, toUId, message.getBytes(StandardCharsets.UTF_8));
    }

    @Override
    protected void setMediaType() {
        type = MessageTypeEnum.TEXT.getCode();
    }

    /**
     * 获取自己的消息
     * @return
     */
    public String getString(){
        return new String(getData(), StandardCharsets.UTF_8);
    }

}
